lexer grammar AnalexMiToken;

options {
  TokenLabelType = Token_file;
  language = Java;
}

tokens {   
  
}   

@lexer::header {
  package Practica4.EBNF;
}

@lexer::members {
	 public Token emit() {
	    Token_file t = new Token_file(input, state.type, state.channel,state.tokenStartCharIndex, getCharIndex()-1);
	    t.setLine(state.tokenStartLine);
	    t.setText(state.text);
	    t.setCharPositionInLine(state.tokenStartCharPositionInLine);
	    t.setFileName(this.getSourceName());
	    emit(t);
	    return t;
	}
	
  private ArrayList<String> errors = new ArrayList<String>();
    public void displayRecognitionError(String[] tokenNames,
                                        RecognitionException e) {
        String hdr = getErrorHeader(e);
        String msg = getErrorMessage(e, tokenNames);
        errors.add(hdr + " " + msg);
    }
    
    public ArrayList<String> getErrors() {
        return errors;
    }
}

fragment DIGITO: '0'..'9';  
fragment LETRA: 'A'..'Z' | 'a'..'z' | '_' | '/' | '&' | ';' | '.';
SALTO_LINEA: ('\r' '\n' | '\r' | '\n') {$channel=HIDDEN;skip();};

BLANCO: (' ' | '\t' | SALTO_LINEA) {skip();};
STRING: LETRA (' ' | SALTO_LINEA | LETRA)*;
COMENTARIO: '<!--' (~'-' | '-'~'-' | '--'~'>')* '-->' {$channel=HIDDEN;skip();};
ID: '<' (LETRA)+ '>';